<template>
  <div>
    小儿子的玩具，{{ toy }}
  </div>
</template>

<script lang="ts" setup>
import emitter from '@/utils/emitter';
import { onUnmounted, ref } from 'vue'

let toy = ref('')
emitter.on('sendToy', (toyName: any) => {
  toy.value = toyName
})

// 页面卸载时，解绑sendToy，避免造成内存浪费，或者说是内存泄漏
onUnmounted(() => {
  emitter.off('sendToy')
})
</script>

<style lang="scss" scoped>

</style>